<html>
<head><meta charset="utf-8"><title>Making rustc_middle faster to compile · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html">Making rustc_middle faster to compile</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211942897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211942897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211942897">(Oct 01 2020 at 17:12)</a>:</h4>
<p>If I wanted to help with <a href="https://github.com/rust-lang/rust/issues/65031">https://github.com/rust-lang/rust/issues/65031</a>, how would I get started? I took a quick glance at the API and it looks like maybe <code>rustc_middle::ich</code> would be a good candidate for splitting out into a separate crate - is that a good approach?</p>



<a name="211945767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211945767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211945767">(Oct 01 2020 at 17:32)</a>:</h4>
<blockquote>
<p>how would I get started?</p>
</blockquote>
<p>It would probably be worth investing some time to trying to figure out what code in the crate is driving the compilation time up so high.</p>



<a name="211946157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211946157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211946157">(Oct 01 2020 at 17:35)</a>:</h4>
<p><code>-Zllvm-time-trace</code> might be worth exploring but I think you will need to disable parallel codegen to use it.</p>
<p><code>-Zprint-mono-items</code> might also be helpful.</p>



<a name="211956137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956137">(Oct 01 2020 at 18:47)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> IMO a good step would also be a PR to rustbuild that lets us get llvm-lines output (as a check alternative like clippy)</p>



<a name="211956530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956530">(Oct 01 2020 at 18:50)</a>:</h4>
<p>ooh I like that</p>



<a name="211956557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956557">(Oct 01 2020 at 18:50)</a>:</h4>
<p>I'll try to work in this area this weekend</p>



<a name="211956723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956723">(Oct 01 2020 at 18:51)</a>:</h4>
<p>would it make sense to have a generic 'unknown cargo command' delegate and try to pass things through to cargo if they're unrecognized? or maybe just have a whitelist of things to pass through?</p>



<a name="211956726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956726">(Oct 01 2020 at 18:51)</a>:</h4>
<p>It would probably be good to split <code>mir</code> out into its own crate, right? Perhaps <code>rustc_middle</code> should only have things that nearly every part of the compiler needs: <code>Ty</code>, arenas, etc. What do you think?</p>



<a name="211956894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956894">(Oct 01 2020 at 18:52)</a>:</h4>
<p>no, I do not want to just allow anything through that seems annoying and hard to deal with at least for now</p>



<a name="211956981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211956981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211956981">(Oct 01 2020 at 18:53)</a>:</h4>
<p><span class="user-mention" data-user-id="307537">@Camelid</span> I would not try to approach this generically or by coming up with a list or anything -- really rustc_middle likely shouldn't exist, it doesn't make sense as a standalone entity imo</p>



<a name="211957055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957055">(Oct 01 2020 at 18:54)</a>:</h4>
<p>I think the steps here are basically to identify some fairly large chunk and try to pull it out -- this is nontrivial, usually.</p>



<a name="211957161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957161">(Oct 01 2020 at 18:54)</a>:</h4>
<p>So are you suggesting (in the long run) that we have a bunch of crates (<code>rustc_ty</code>, <code>rustc_arena</code> -- those names may be taken) that represent exactly one set of things, and remove <code>rustc_middle</code>?</p>



<a name="211957261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957261">(Oct 01 2020 at 18:55)</a>:</h4>
<p>If so, that sounds like a good way to approach it</p>



<a name="211957268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957268">(Oct 01 2020 at 18:55)</a>:</h4>
<p>Sure, I think that's probably the right thing. There will be some amount of rustc_middle-like crate which defines things, but basically it shouldn't be too large</p>



<a name="211957310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957310">(Oct 01 2020 at 18:55)</a>:</h4>
<p>Yeah, but they won't all be thrown together in one crate :)</p>



<a name="211957312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957312">(Oct 01 2020 at 18:55)</a>:</h4>
<p>Certainly I think <em>logic</em> bits probably can move out, even if connector glue of some kind remains.</p>



<a name="211957365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957365">(Oct 01 2020 at 18:55)</a>:</h4>
<p>Maybe there would be a few utility functions that would be nice to have -- rename to <code>rustc_utility</code>?</p>



<a name="211957482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957482">(Oct 01 2020 at 18:56)</a>:</h4>
<p>I think we should see what's making it slow in the first place</p>



<a name="211957506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957506">(Oct 01 2020 at 18:56)</a>:</h4>
<p>just moving things around doesn't actually make it faster, just more parallel</p>



<a name="211957557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957557">(Oct 01 2020 at 18:57)</a>:</h4>
<p>That should make it faster in wall-clock time though</p>



<a name="211957564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957564">(Oct 01 2020 at 18:57)</a>:</h4>
<p>Yes, but that will already solve things like memory &gt;4GB and such. Realistically splitting apart that crate just because of that is fine.</p>



<a name="211957687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211957687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211957687">(Oct 01 2020 at 18:58)</a>:</h4>
<p>fwiw I don't expect to find any big "silver bullets" here or anything like that -- it's just a huge crate. The source, before expansion, is already 2MB.</p>



<a name="211958069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211958069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211958069">(Oct 01 2020 at 19:01)</a>:</h4>
<p>And 46K lines of code (including comments and blanks) according to tokei</p>



<a name="211958096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211958096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211958096">(Oct 01 2020 at 19:01)</a>:</h4>
<p>In some ways I'm surprised it's not more</p>



<a name="211958433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/211958433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#211958433">(Oct 01 2020 at 19:03)</a>:</h4>
<p>Why is trait resolution in <code>rustc_middle</code> and not <code>rustc_typeck</code> or its own crate?</p>



<a name="212153174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212153174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212153174">(Oct 03 2020 at 04:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125250">Wesley Wiser</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/211946157">said</a>:</p>
<blockquote>
<p><code>-Zllvm-time-trace</code> might be worth exploring but I think you will need to disable parallel codegen to use it.</p>
<p><code>-Zprint-mono-items</code> might also be helpful.</p>
</blockquote>
<p>unfortunately <code>llvm-time-trace</code> gave nothing useful, I think the file might be being overwritten?</p>
<div class="codehilite"><pre><span></span><code>$ cat llvm_timings.json
{&quot;traceEvents&quot;:[{&quot;cat&quot;:&quot;&quot;,&quot;pid&quot;:16371,&quot;tid&quot;:16372,&quot;ts&quot;:0,&quot;ph&quot;:&quot;M&quot;,&quot;name&quot;:&quot;process_name&quot;,&quot;args&quot;:{&quot;name&quot;:&quot;rustc&quot;}},{&quot;cat&quot;:&quot;&quot;,&quot;pid&quot;:16371,&quot;tid&quot;:16372,&quot;ts&quot;:0,&quot;ph&quot;:&quot;M&quot;,&quot;name&quot;:&quot;thread_name&quot;,&quot;args&quot;:{&quot;name&quot;:&quot;&quot;}}],&quot;beginningOfTime&quot;:1601699236094356}
</code></pre></div>



<a name="212153192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212153192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212153192">(Oct 03 2020 at 04:45)</a>:</h4>
<p>wow, <code>print-mono-items</code> has a <em>lot</em> of output</p>



<a name="212154206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154206">(Oct 03 2020 at 05:20)</a>:</h4>
<p>well this is exciting <a href="https://github.com/rust-lang/rust/issues/77478">https://github.com/rust-lang/rust/issues/77478</a></p>



<a name="212154272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154272">(Oct 03 2020 at 05:23)</a>:</h4>
<p>oh boy</p>
<div class="codehilite"><pre><span></span><code>$ grep rustc_middle mono-items.log | wc -l
634285
</code></pre></div>



<a name="212154310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154310">(Oct 03 2020 at 05:24)</a>:</h4>
<p>out of a total of <code>1176865</code></p>



<a name="212154312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154312">(Oct 03 2020 at 05:24)</a>:</h4>
<p><em>wow</em>, that's more than half of all mono items just from rustc_middle</p>



<a name="212154321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154321">(Oct 03 2020 at 05:25)</a>:</h4>
<p>oh that's <em>everything</em> that has the word rustc_middle, it's much smaller if you only count things defined in that crate:</p>
<div class="codehilite"><pre><span></span><code>$ cut -d &#39; &#39; -f -3 mono-items.log  | grep &#39; rustc_middle&#39; | wc -l
89836
</code></pre></div>



<a name="212154369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154369">(Oct 03 2020 at 05:27)</a>:</h4>
<p>and yes this is definitely showing the same functions being monomorphized over and over again</p>
<div class="codehilite"><pre><span></span><code>$ cut -d &#39; &#39; -f -3 mono-items.log  | grep &#39; rustc_middle&#39; | sort | uniq -c | sort -k 1  | head -n 20
    100 MONO_ITEM fn rustc_middle::ty[0]::context[0]::{{impl}}[31]::struct_span_lint_hir[0]&lt;rustc_span::span_encoding[0]::Span[0],
    103 MONO_ITEM fn rustc_middle::ty[0]::query[0]::on_disk_cache[0]::decode_tagged[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0],
     10 MONO_ITEM fn rustc_middle::middle[0]::codegen_fn_attrs[0]::_DERIVE_rustc_serialize_Decodable_D_FOR_CodegenFnAttrFlags[0]::{{impl}}[0]::decode[0]::{{closure}}[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0],
     10 MONO_ITEM fn rustc_middle::middle[0]::codegen_fn_attrs[0]::_DERIVE_rustc_serialize_Decodable_D_FOR_CodegenFnAttrFlags[0]::{{impl}}[0]::decode[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0]&gt;
     10 MONO_ITEM fn rustc_middle::middle[0]::codegen_fn_attrs[0]::_DERIVE_rustc_serialize_Decodable_D_FOR_CodegenFnAttrs[0]::{{impl}}[0]::decode[0]::{{closure}}[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0],
     10 MONO_ITEM fn rustc_middle::middle[0]::codegen_fn_attrs[0]::_DERIVE_rustc_serialize_Decodable_D_FOR_CodegenFnAttrs[0]::{{impl}}[0]::decode[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0]&gt;
     10 MONO_ITEM fn rustc_middle::mir[0]::{{impl}}[8]::decode[0]&lt;rustc_middle::ty[0]::query[0]::on_disk_cache[0]::CacheDecoder[0],
     10 MONO_ITEM fn rustc_middle::mir[0]::interpret[0]::allocation[0]::{{impl}}[4]::get_bytes_internal[0]&lt;(),
</code></pre></div>



<a name="212154459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154459">(Oct 03 2020 at 05:30)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> you're right that a lot of statics are being generated by tracing</p>
<div class="codehilite"><pre><span></span><code>$ grep &#39;CALLSITE&#39; mono-items.log  | wc -l
3087
</code></pre></div>


<p><a href="https://github.com/tokio-rs/tracing/issues/921">https://github.com/tokio-rs/tracing/issues/921</a></p>



<a name="212154460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154460">(Oct 03 2020 at 05:30)</a>:</h4>
<p>not a ton compared to the number of total items though</p>



<a name="212154467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154467">(Oct 03 2020 at 05:31)</a>:</h4>
<p>(cc <span class="user-mention" data-user-id="307286">@Eliza Weisman</span> )</p>



<a name="212154523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154523">(Oct 03 2020 at 05:33)</a>:</h4>
<p>here are the items ordered by crate:</p>
<div class="codehilite"><pre><span></span><code>$ grep -o &#39;fn rustc_[^:]*&#39;  mono-items.log | cut -d &#39; &#39; -f 2 | sort | uniq -c | sort -k1 -h | tail -n 10
   2978 rustc_lint
   3007 rustc_target
   3136 rustc_span
   5508 rustc_mir
   8666 rustc_hir
   9301 rustc_ast
  14481 rustc_data_structures
  21051 rustc_serialize
  35012 rustc_query_system
  89581 rustc_middle
</code></pre></div>



<a name="212154672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154672">(Oct 03 2020 at 05:38)</a>:</h4>
<p>among rustc_middle, the worst offender is <code>ty</code> by far:</p>
<div class="codehilite"><pre><span></span><code>     49 fn rustc_middle::util[0]
    153 fn rustc_middle::lint[0]
    182 fn rustc_middle::ich[0]
    216 fn rustc_middle::arena[0]
    387 fn rustc_middle::hir[0]
    583 fn rustc_middle::middle[0]
    680 fn rustc_middle::query[0]
    744 fn rustc_middle::infer[0]
    870 fn rustc_middle::traits[0]
   5263 fn rustc_middle::dep_graph[0]
   7550 fn rustc_middle::mir[0]
  72904 fn rustc_middle::ty[0]
</code></pre></div>



<a name="212154675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154675">(Oct 03 2020 at 05:38)</a>:</h4>
<p>ok, let me try moving <code>ty</code> out. probably it will be hard because so much depends on it</p>



<a name="212154727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212154727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212154727">(Oct 03 2020 at 05:40)</a>:</h4>
<p>does anyone know the difference between <code>rustc_ty</code> and <code>rustc_middle::ty</code>? Is there any reason not to make them both the same crate?</p>



<a name="212157622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212157622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212157622">(Oct 03 2020 at 07:07)</a>:</h4>
<p>yesssss</p>
<div class="codehilite"><pre><span></span><code>warning: publicly re-exporting an item
  --&gt; compiler/rustc_lint/src/builtin.rs:62:1
   |
62 | pub use rustc_session::lint::builtin::*;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-W rustc::pub-cross-crate-reexport` implied by `-W rustc::internal`
   = note: facade crates are discouraged; import from the original crate instead
</code></pre></div>



<a name="212158181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212158181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212158181">(Oct 03 2020 at 07:23)</a>:</h4>
<p>oh haha <span class="user-mention" data-user-id="216206">@lcnr</span> you got assigned to the PR <a href="https://github.com/rust-lang/rust/pull/77479">https://github.com/rust-lang/rust/pull/77479</a></p>



<a name="212158410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212158410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212158410">(Oct 03 2020 at 07:28)</a>:</h4>
<p>do you think I should ping t-compiler on it? it is a bit of an invasive change</p>



<a name="212158890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212158890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212158890">(Oct 03 2020 at 07:42)</a>:</h4>
<p>I personally think that lint is a good idea but  do think we should have an MCP or even FCP here though as this is a fairly clear statement of direction afaict and iirc <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> had some reservations here. These might just have been about a specific instance which we can just <code>allow</code> but I still think it's better to get at least some broader consensus here.</p>



<a name="212158913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212158913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212158913">(Oct 03 2020 at 07:43)</a>:</h4>
<p>sure, MCP seems helpful</p>



<a name="212159513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159513">(Oct 03 2020 at 07:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212158890">said</a>:</p>
<blockquote>
<p>and iirc <span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> had some reservations here.</p>
</blockquote>
<p>No reservations, please proceed with removing the reexports.<br>
(I'll look at those PRs anyway and write if I'm against some specific changes.)</p>



<a name="212159579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159579">(Oct 03 2020 at 08:00)</a>:</h4>
<p>I'm not sure about the lint, it will give a lot of warnings - ~400 instances of <code>pub use</code> in <code>compiler</code> right now.</p>



<a name="212159592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159592">(Oct 03 2020 at 08:01)</a>:</h4>
<p>maybe it makes sense to first clean up most of the re-exports and only then add the lint?</p>



<a name="212159598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159598">(Oct 03 2020 at 08:01)</a>:</h4>
<p>Ah, the lint detects only reexport from other crates, I see.</p>



<a name="212159616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159616">(Oct 03 2020 at 08:02)</a>:</h4>
<p>having the lint helps me find the exports in the first place but I'm fine with working off a local copy in the meantime, I made a list at <a href="https://github.com/rust-lang/rust/pull/77479#issuecomment-703061465">https://github.com/rust-lang/rust/pull/77479#issuecomment-703061465</a></p>



<a name="212159646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159646">(Oct 03 2020 at 08:02)</a>:</h4>
<p>can someone merge this stream with <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Internal.20lint.3A.20Ban.20.60pub.60.20re-exports.20in.20co.E2.80.A6.20compiler-team.23368">https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Internal.20lint.3A.20Ban.20.60pub.60.20re-exports.20in.20co.E2.80.A6.20compiler-team.23368</a> please?</p>



<a name="212159651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159651">(Oct 03 2020 at 08:02)</a>:</h4>
<p>starting from around <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212157622">https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212157622</a></p>



<a name="212159703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212159703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212159703">(Oct 03 2020 at 08:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212159598">said</a>:</p>
<blockquote>
<p>Ah, the lint detects only reexport from other crates, I see.</p>
</blockquote>
<p>I could possibly extend it later to detect <code>pub use self::x::Item;</code> if <code>x</code> is public, but that definitely doesn't need to be in the first pass</p>



<a name="212160066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160066">(Oct 03 2020 at 08:14)</a>:</h4>
<p>Considering that the lint is <code>allow</code> by default I think it's good to just add it and then slowly add <code>warn</code>s to the different crates</p>



<a name="212160086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160086">(Oct 03 2020 at 08:15)</a>:</h4>
<p>somewhat related, <span class="user-mention" data-user-id="232545">@Joshua Nelson</span> do you know how hard it is to lint things like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">inner</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">use</span><span class="w"> </span><span class="k">super</span>::<span class="n">Item</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="c1">//~^ WARN import of private use statement</span>
<span class="p">}</span><span class="w"></span>

<span class="k">use</span><span class="w"> </span><span class="n">other</span>::<span class="n">Item</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="212160137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160137">(Oct 03 2020 at 08:16)</a>:</h4>
<p>That seems not too hard to do, I could check if <code>Item</code> was defined in <code>super</code> or not</p>



<a name="212160147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160147">(Oct 03 2020 at 08:17)</a>:</h4>
<blockquote>
<p>Considering that the lint is <code>allow</code> by default I think it's good to just add it and then slowly add <code>warn</code>s to the different crates</p>
</blockquote>
<p>It's not actually allowed by default, it's warn by default because it's in the <code>rustc</code> lint group</p>



<a name="212160196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160196">(Oct 03 2020 at 08:18)</a>:</h4>
<p>I would prefer it to be opt out instead of opt-in, which is why I suggested changing the re-exports before adding the lint. Another alternative is to not yet add it to the lint group so it's opt-in for now, then add it later.</p>



<a name="212160206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160206">(Oct 03 2020 at 08:19)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> your idea seems like it could be a clippy lint regardless of what rustc does, it's not specific to the compiler</p>



<a name="212160263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160263">(Oct 03 2020 at 08:20)</a>:</h4>
<p>(related: <a href="https://github.com/rust-lang/rust/pull/77351">https://github.com/rust-lang/rust/pull/77351</a>)</p>



<a name="212160265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160265">(Oct 03 2020 at 08:20)</a>:</h4>
<blockquote>
<p>I would prefer it to be opt out instead of opt-in</p>
</blockquote>
<p>yeah, my idea would be to add it as allow and then fix all desired occurrences and only then change this to warn by default</p>



<a name="212160278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212160278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212160278">(Oct 03 2020 at 08:21)</a>:</h4>
<blockquote>
<p>maybe it makes sense to first clean up most of the re-exports and only then add the lint?</p>
</blockquote>
<p>so that we start by adding the lint here</p>



<a name="212162308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212162308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212162308">(Oct 03 2020 at 09:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212154727">said</a>:</p>
<blockquote>
<p>does anyone know the difference between <code>rustc_ty</code> and <code>rustc_middle::ty</code>? Is there any reason not to make them both the same crate?</p>
</blockquote>
<p>many of rustc_middle 's submodules have matchings in their name rustc_middle::hir, rustc_middle::mir, etc. I'm not sure why though.</p>



<a name="212162328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212162328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212162328">(Oct 03 2020 at 09:19)</a>:</h4>
<p>It used to be even weirder back when the crate was called rustc. You had rustc::mir and rustc_mir :)</p>



<a name="212162399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212162399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212162399">(Oct 03 2020 at 09:20)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L1">https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L1</a></p>



<a name="212162424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212162424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> est31 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212162424">(Oct 03 2020 at 09:21)</a>:</h4>
<p>Apparently it's the definitions which are in the crate. That's what I remember as well. Maybe it would make sense to have rustc_def_* crates for each of the submodules. As in rustc_def_mir etc.</p>



<a name="212168673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212168673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212168673">(Oct 03 2020 at 12:09)</a>:</h4>
<p>IIRC, the worst offender is the query system, which generates a <em>lot</em> of symbols inside <code>rustc_middle::ty::query</code>. A tentative extraction was done, with the compilation time measurement in <a href="https://github.com/rust-lang/rust/pull/70951#issuecomment-611564529">https://github.com/rust-lang/rust/pull/70951#issuecomment-611564529</a>. In short, most of the codegen time is query-related.</p>



<a name="212170463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212170463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212170463">(Oct 03 2020 at 12:59)</a>:</h4>
<p>So, that looks a little more ambitious than I was planning</p>



<a name="212170514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212170514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212170514">(Oct 03 2020 at 13:00)</a>:</h4>
<p>Rather than splitting rustc_middle into crates, it changes the <em>design</em> of the query system</p>



<a name="212170525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212170525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212170525">(Oct 03 2020 at 13:01)</a>:</h4>
<p>I was hoping we could get some of the benefit without such sweeping changes</p>



<a name="212184129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212184129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212184129">(Oct 03 2020 at 18:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212154727">said</a>:</p>
<blockquote>
<p>does anyone know the difference between <code>rustc_ty</code> and <code>rustc_middle::ty</code>? Is there any reason not to make them both the same crate?</p>
</blockquote>
<p>I wondered the same thing. Plus there's <code>rustc_middle::hir</code> and <code>rustc_hir</code> and others <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="212185471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212185471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212185471">(Oct 03 2020 at 19:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212154727">said</a>:</p>
<blockquote>
<p>does anyone know the difference between <code>rustc_ty</code> and <code>rustc_middle::ty</code>? Is there any reason not to make them both the same crate?</p>
</blockquote>
<p><code>rustc_middle::ty</code> is definitions for types representing various type-system concepts (and also a bunch of query-system stuff that lives in a submodule for some reason). <code>rustc_ty</code> is a bunch of query providers that are vaguely type-system related, but don't need to live in <code>rustc_typeck</code>. </p>
<p><code>rustc_middle::mir</code> vs. <code>rustc_mir</code> is similar. But <code>rustc_hir</code> is actually  a dependency of <code>rustc_middle</code> (<code>rustc_passes</code> is more analogous to <code>rustc_mir</code>)</p>
<p>A lot of <code>rustc_ty</code> used to live in <code>rustc_middle::ty</code>, but was moved out to improve compile-times. Since many queries use types in <code>rustc_middle::ty</code> they can only be moved to a crate that's depended on by <code>rustc_middle</code> rather than the other way around.</p>



<a name="212187158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212187158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212187158">(Oct 03 2020 at 19:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120096">est31</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212162424">said</a>:</p>
<blockquote>
<p>Apparently it's the definitions which are in the crate. That's what I remember as well. Maybe it would make sense to have rustc_def_* crates for each of the submodules. As in rustc_def_mir etc.</p>
</blockquote>
<p>I think it would be better to have e.g. <code>rustc_mir</code> be definitions for MIR and then rename <code>rustc_mir</code> to <code>rustc_mir_analysis</code> or something. And then <code>rustc_ty</code> would have type definitions and the current <code>rustc_ty</code> would be renamed <code>rustc_ty_query</code> or something. Probably there would be too much friction in making that change though :/</p>



<a name="212218120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212218120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212218120">(Oct 04 2020 at 11:01)</a>:</h4>
<p>there's also some Miri interpreter logic in <code>librustc_middle::mir::interpret</code>... the annoying thing is that types like <code>Alloc</code> appear as query return types, so to have properly encapsulated logic on their private fields, <code>Alloc</code> and all of its logic must be in <code>rustc_middle</code> :/<br>
(and this logic is subtle, making these fields public is not really an option)</p>
<p>For a similar, reason, all the logic of <code>Scalar</code> and <code>Pointer</code> is in that crate.</p>



<a name="212218172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212218172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212218172">(Oct 04 2020 at 11:03)</a>:</h4>
<p>We can move anything that does not depend on types into a separate crate that rustc_middle depends on</p>



<a name="212218236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212218236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212218236">(Oct 04 2020 at 11:05)</a>:</h4>
<p>hm, I guess the scalar and pointer stuff could qualify? not sure about the alloc stuff... and I'd rather not spread the interpreter across <em>three</em> crates^^</p>



<a name="212218354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212218354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212218354">(Oct 04 2020 at 11:09)</a>:</h4>
<p>Does anything need types anymore? Maybe some methods but these could likely be made generic over the Ty (in case they just look at the layout)</p>



<a name="212232761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212232761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212232761">(Oct 04 2020 at 17:39)</a>:</h4>
<p>Maybe this was already said, but potentially a good way to start splitting up <code>rustc_middle</code> would be to create different crates for the different modules (<code>rustc_def_ty</code>, <code>rustc_def_mir</code>, etc.) and then re-export (<span class="user-mention" data-user-id="232545">@Joshua Nelson</span> will love this) those crates from the modules. And then after that we can get rid of the re-exports. This way the work is split into two steps that will both compile.</p>



<a name="212260371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212260371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> csmoe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212260371">(Oct 05 2020 at 05:31)</a>:</h4>
<p>kind of off-topic, will splitting benefit a huge rust project(about 1.8 million lines) with <code>codegen-units=1 lto=fat</code> at release mode? cc <span class="user-mention" data-user-id="125250">@Wesley Wiser</span></p>



<a name="212260653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212260653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> csmoe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212260653">(Oct 05 2020 at 05:38)</a>:</h4>
<p>the compile time of our rust sdk makes the dev workflow really hard.</p>



<a name="212297825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212297825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212297825">(Oct 05 2020 at 13:22)</a>:</h4>
<p>It makes it more parallel and use less memory (hopefully). It does not decrease the CPU time.</p>



<a name="212357653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212357653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212357653">(Oct 05 2020 at 21:13)</a>:</h4>
<p>So I think it would likely reduce wall clock time if you have multiple cores</p>



<a name="212932534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212932534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212932534">(Oct 10 2020 at 20:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116118">Matthew Jasper</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212185471">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile/near/212154727">said</a>:</p>
<blockquote>
<p>does anyone know the difference between <code>rustc_ty</code> and <code>rustc_middle::ty</code>? Is there any reason not to make them both the same crate?</p>
</blockquote>
<p><code>rustc_middle::ty</code> is definitions for types representing various type-system concepts (and also a bunch of query-system stuff that lives in a submodule for some reason). <code>rustc_ty</code> is a bunch of query providers that are vaguely type-system related, but don't need to live in <code>rustc_typeck</code>. </p>
<p><code>rustc_middle::mir</code> vs. <code>rustc_mir</code> is similar. But <code>rustc_hir</code> is actually  a dependency of <code>rustc_middle</code> (<code>rustc_passes</code> is more analogous to <code>rustc_mir</code>)</p>
<p>A lot of <code>rustc_ty</code> used to live in <code>rustc_middle::ty</code>, but was moved out to improve compile-times. Since many queries use types in <code>rustc_middle::ty</code> they can only be moved to a crate that's depended on by <code>rustc_middle</code> rather than the other way around.</p>
</blockquote>
<p>how does it sounds to move ~most of the rest of <code>rustc_middle::ty</code> to <code>rustc_ty</code>?</p>



<a name="212932577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212932577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212932577">(Oct 10 2020 at 20:08)</a>:</h4>
<p>oh I see rustc_ty depends on rustc_middle, not the other way around</p>



<a name="212932578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212932578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212932578">(Oct 10 2020 at 20:08)</a>:</h4>
<p>oof</p>



<a name="212932590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212932590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212932590">(Oct 10 2020 at 20:08)</a>:</h4>
<p>ok instead I'm going to look at moving <code>rustc_middle::ty::query</code> to <code>rustc_query</code></p>



<a name="212932596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212932596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212932596">(Oct 10 2020 at 20:08)</a>:</h4>
<p>and see how badly that goes <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="212933023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933023">(Oct 10 2020 at 20:20)</a>:</h4>
<p>update: badly <a href="https://hastebin.com/imakobujuc.rust">https://hastebin.com/imakobujuc.rust</a></p>



<a name="212933294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933294">(Oct 10 2020 at 20:28)</a>:</h4>
<p>I tried going the other way: making <code>rustc_query</code> depend on <code>rustc_middle</code>, and that seems to be going a little better: <a href="https://paste.rs/lrm.rs">https://paste.rs/lrm.rs</a></p>
<p>The main issue is that lots of things in <code>rustc_middle::ty</code> depend on <code>Providers</code></p>



<a name="212933305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933305">(Oct 10 2020 at 20:29)</a>:</h4>
<p>maybe instead of having <code>fn provide</code> throughout rustc_middle, <code>rustc_query</code> could add those functions as the defaults? Since query would have access to the functions but <code>middle</code> wouldn't have access to <code>Providers</code></p>



<a name="212933361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933361">(Oct 10 2020 at 20:30)</a>:</h4>
<p>ah wait no that breaks <code>create_global_ctxt</code>, booo</p>



<a name="212933622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933622">(Oct 10 2020 at 20:39)</a>:</h4>
<p>ok here's an idea: the only thing <code>rustc_middle::middle::cstore</code> uses is <code>TyCtxt</code>, and that's only for</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">fn</span> <span class="nf">encode_metadata</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">tcx</span>: <span class="nc">TyCtxt</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">EncodedMetadata</span><span class="p">;</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">used_crates</span><span class="p">(</span><span class="n">tcx</span>: <span class="nc">TyCtxt</span><span class="o">&lt;'</span><span class="nb">_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">prefer</span>: <span class="nc">LinkagePreference</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Vec</span><span class="o">&lt;</span><span class="p">(</span><span class="n">CrateNum</span><span class="p">,</span><span class="w"> </span><span class="n">LibSource</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="o">..</span><span class="p">.</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>maybe that could be broken up somehow with extension traits?</p>



<a name="212933671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933671">(Oct 10 2020 at 20:40)</a>:</h4>
<p>hmm <code>CrateStore</code> is already a trait though ...</p>



<a name="212933953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212933953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212933953">(Oct 10 2020 at 20:49)</a>:</h4>
<p>I tried changing <code>used_crates</code> to take <code>impl QueryContext</code> instead, but that didn't work either since it needs some of the queries:</p>
<div class="codehilite"><pre><span></span><code>error[E0599]: no method named `dep_kind` found for type parameter `CTX` in the current scope
   --&gt; compiler/rustc_middle/src/middle/cstore.rs:227:20
    |
227 |             if tcx.dep_kind(cnum).macros_only() {
    |                    ^^^^^^^^ method not found in `CTX`
</code></pre></div>



<a name="212934224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934224">(Oct 10 2020 at 20:57)</a>:</h4>
<p>I tried making <code>CrateStore</code> have an associated <code>type CTX: QueryContext</code> but that <em>also</em> doesn't work because that means you now need <code>type CrateStoreDyn&lt;'tcx&gt; = dyn CrateStore&lt;TyCtxt&lt;'tcx&gt;&gt; + sync::Sync;</code> and now the lifetimes infect everything (I got to <code>ResolverOutputs</code> before giving up)</p>



<a name="212934300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934300">(Oct 10 2020 at 20:59)</a>:</h4>
<p>it looks like the only places that actually use <code>encode_metadata</code> are</p>
<div class="codehilite"><pre><span></span><code>rustc_middle/src/ty/context.rs
1280:    pub fn encode_metadata(self) -&gt; EncodedMetadata {
1282:        self.cstore.encode_metadata(self)

rustc_interface/src/passes.rs
944:        MetadataKind::Uncompressed | MetadataKind::Compressed =&gt; tcx.encode_metadata(),
</code></pre></div>


<p>maybe instead of making it part of the trait, it could be a free function?</p>



<a name="212934436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934436">(Oct 10 2020 at 21:03)</a>:</h4>
<p>why is there only <code>cstore_as_any()</code> but not <code>cstore()</code>?</p>



<a name="212934509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934509">(Oct 10 2020 at 21:04)</a>:</h4>
<p>oh I see the issue, <code>tcx.cstore</code> is <code>CrateStoreDyn</code>, not <code>CStore</code>, so it doesn't help to have inherent impls</p>



<a name="212934510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934510">(Oct 10 2020 at 21:04)</a>:</h4>
<p>ugh</p>



<a name="212934865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212934865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212934865">(Oct 10 2020 at 21:14)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> you probably have ideas about this - do you think there's a way to separate <code>CrateStore</code> and <code>TyCtxt</code> into different crates? If there was I could separate a lot more things, like <code>rustc_middle::ich</code> (at least part of it).</p>



<a name="212935783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212935783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212935783">(Oct 10 2020 at 21:40)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span>: Did you look ad <a href="https://github.com/rust-lang/rust/issues/70951">#70951</a>? The <code>QueryEngine</code> trait there gives a way to untangle the <code>ty::query</code> spaghetti. It can certainly be improved upon.</p>



<a name="212935796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212935796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212935796">(Oct 10 2020 at 21:40)</a>:</h4>
<p>Without changing the design, you can get an idea of where the knot is tied.</p>



<a name="212935973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212935973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212935973">(Oct 10 2020 at 21:44)</a>:</h4>
<p>wow, I'm with you on <a href="https://github.com/rust-lang/rust/pull/70951#issuecomment-611582538">https://github.com/rust-lang/rust/pull/70951#issuecomment-611582538</a></p>



<a name="212936331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936331">(Oct 10 2020 at 21:54)</a>:</h4>
<p>I don't think I understand queries well enough to understand your change :/</p>



<a name="212936370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936370">(Oct 10 2020 at 21:54)</a>:</h4>
<p>why did moving only a few methods to <code>QueryCtxt</code> instead of <code>TyCtxt</code> work?</p>



<a name="212936480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936480">(Oct 10 2020 at 21:57)</a>:</h4>
<p>in any case <a href="https://github.com/rust-lang/rust/pull/70951#issuecomment-611582538">https://github.com/rust-lang/rust/pull/70951#issuecomment-611582538</a> makes it seem like splitting up the crate alone is not enough, some part of the approach has to change or we're just moving the compile times around</p>



<a name="212936633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936633">(Oct 10 2020 at 22:01)</a>:</h4>
<p>QueryCtxt exists so it knows the real types of the queries. As a consequence, it can implement rustc_query_system::query::QueryContext, where TyCtxt cannot. Because of the <code>impl Deref for QueryCtxt</code>, both types behave the same most of the time.</p>



<a name="212936642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936642">(Oct 10 2020 at 22:01)</a>:</h4>
<p>Moving compile time around is not enough, yes. It may, or may not help, depending on parallelism.</p>



<a name="212936706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Making%20rustc_middle%20faster%20to%20compile/near/212936706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Making.20rustc_middle.20faster.20to.20compile.html#212936706">(Oct 10 2020 at 22:03)</a>:</h4>
<p>I have a branch (<a href="https://github.com/cjgillot/rust/tree/query-merge">https://github.com/cjgillot/rust/tree/query-merge</a>) where I try to simplify the generated code. It is far from ready, but I welcome ideas.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>